#ifndef WSCREQUESTHANDLER_H
#define WSCREQUESTHANDLER_H

#include <QObject>
#include "../../../QtWebApp/current/lib/bfHttpServer/src/httpresponse.h"
#include "../../../QtWebApp/current/lib/bfHttpServer/src/httprequest.h"
#include "../../../QtWebApp/current/lib/bfHttpServer/src/httplistener.h"
#include "../../../QtWebApp/current/lib/bfHttpServer/src/staticfilecontroller.h"
#include "../FsxWsUtils/jsonmarkuphelper.h"
#include "../FsxWsUtils/httphelper.h"
using namespace FsxWsUtils;

namespace FsxWebService {

//! Base class for "my" request handlers
class WscRequestHandler : public HttpRequestHandler
{
private:
    QString _path; /*!< path (URL path) */
    QString _serverUrl; /*!< server URL */
    int _port; /*!< port */

protected:
    //! Constructor
    /*! \param port
        \param serverUrl
        \param path
        \param parent */
    WscRequestHandler(const int port, const QString &serverUrl, const QString &path, QObject *parent=0);
    //! Set the port
    /*! \param port */
    void setPort(const int port) { _port = port; }

public:
    //! Current path
    /*! \return path */
    const QString getPath() const { return _path; }
    //! Server url
    /*! \return url */
    const QString getServerUrl() const { return _serverUrl; }
    //! Server url and path
    /*! \return url */
    const QString getFullUrl() const { HttpHelper::appendToUrl(getServerUrl(), getPath()); }
    //! IP port
    /*! \return port */
    const int getPort() const { return _port; }
    //! Current path mathcing given path
    /*! \param path candidate
        \return matching */
    const bool isMatchingPath (const QString &path) const;
};
}
#endif // WSCREQUESTHANDLER_H
